<?php echo $javascript->link('prototype.js');?>
<div class="topicos index">
<?php echo "Tema:".$tema['nombre'] ?>
<h2><?php __('Topicos');?></h2>
<p>
<?php
$paginator->options(array('url' => $tema['tema']));
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
	<th><?php echo $paginator->sort('titulo','titulo');?></th>
	<th><?php echo $paginator->sort('Creado Por','User.username');?></th>
	<th><?php echo $paginator->sort('fecha','fecha');?></th>
	<th><?php echo $paginator->sort('Cantidad de Posts','cantidad');?></th>
	<?php if($grupo_id == 1){ //cuando es administrador sale las acciones edit y delete
		echo '<th class="actions"><?php __(\'Acciones\');?></th>';
	}?>
</tr>
<?php
$i = 0;
foreach ($topicos as $topico):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
			<?php echo $html->link($topico['Topico']['titulo'], array('controller'=> 'posts', 'action'=>'index', $topico['Topico']['topico'])); ?>
		</td>
		<td>
			<?php echo $topico['User']['username']; ?>
		</td>
		<td>
			<?php echo $topico['Topico']['fecha']; ?>
		</td>
		<td>
			<?php echo $topico['Topico']['cantidad']; ?>
		</td>
		<?php if($grupo_id == 1){ //que solo el administrador pueda modificar el topico o borrar
			echo '<td class="actions">';
				echo $html->link(__('Edit', true), array('action'=>'edit', $topico['Topico']['topico'],$tema['tema'])); 
				echo $html->link(__('Delete', true), array('action'=>'delete', $topico['Topico']['topico'],$tema['tema']), null, sprintf(__('Are you sure you want to delete # %s?', true), $topico['Topico']['titulo']));
			echo '</td>';
		}?>
	</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
  	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>
</div>
<div class="actions">
	<ul>	<li><?php echo $html->link(__('Lista Temas', true), array('controller' => 'temas','action'=>'index')); ?></li>
		<li><?php if($grupo_id ==3 || $grupo_id ==2|| $grupo_id ==1){ //A partir del Trial puede agregar topicos
			echo $html->link(__('Nuevo Topico', true), array('action'=>'add', $tema['tema'])); }?></li>
	</ul>
</div>
